﻿/**********************************************************************
 * @file   GUIAbsPostCurvePlotWidget.h
 * @brief  后处理曲线抽象窗口类声明
 * @author liuzhonghua (liuzhonghuaszch@163.com)
 * @date   2025-02-19
 *********************************************************************/
#ifndef _GUIAbsPostCurvePlotWidget_H
#define _GUIAbsPostCurvePlotWidget_H

#include "GUIPostDialogAPI.h"
#include "GUIWidget/GUIWidgetBase.h"

namespace Core {
    class FITKActionOperator;
}

namespace Plot {
    class FITKXYPlotWindow;
    class FITKXYPlotProperty;
}

namespace Ui {
    class GUIAbsPostCurvePlotWidget;
}

class QTableWidget;

namespace GUI
{
    class GUICurvePlotSettingsDialog;
    /**
     * @brief  CSV参数结果图窗口
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2024-12-31
     */
    class GUIPostDialogAPI GUIAbsPostCurvePlotWidget : public GUIWidgetBase
    {
        Q_OBJECT
    public:
        /**
         * @brief  create object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-31
         */
        GUIAbsPostCurvePlotWidget(Core::FITKActionOperator* oper, QWidget *parent = nullptr, bool isAotoDelete = true);
        /**
         * @brief    Destroy object
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-31
         */
        virtual ~GUIAbsPostCurvePlotWidget();
        /**
         * @brief    获取曲线属性
         * @return   Plot::FITKXYPlotProperty *
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-25
         */
        Plot::FITKXYPlotProperty* getCurvePlotProp();
        /**
         * @brief    初始化表格和曲线
         * @param[i] freqValue
         * @param[i] paraValue
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-19
         */
        virtual void initTableAndCurvePlot(std::vector<float>* freqValue, QHash<QString, std::vector<float>>* paraValue);
        /**
         * @brief    设置DB的乘积
         * @param[i] v 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-03-07
         */
        void setDBDefault(double v);

    protected slots:
        /**
         * @brief  曲线选项操作完成槽
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-21
         */
        void curvePlotOptionSlot();

    protected:
        /**
         * @brief  初始化窗口
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-19
         */
        void initWindow();
        /**
         * @brief    double 转 String
         * @param[i] value 
         * @return   QString
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-21
         */
        QString doubleToString(double value);
        /**
         * @brief    更新表格和曲线数据
         * @param[i] freqRange 
         * @param[i] isAWeight 
         * @param[i] dBValue 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-21
         */
        void updateTableAndCurvePlot(double* freqRange = nullptr, bool isAWeight = false, double dBValue = -1.0);

        double calcParaData(double value, double freqValue, bool isAWei, double dbUserValue);
        double calcOverAll(double value, bool isAWei, double dbUserValue, bool isAll);
        double getAWeightingValue(double freq);

    protected:
        /**
         * @brief ui object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-10-23
         */
        Ui::GUIAbsPostCurvePlotWidget* _ui = nullptr;
        /**
         * @brief 操作器对象
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-10-23
         */
        Core::FITKActionOperator* _oper = nullptr;
        /**
         * @brief  参数表格
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-18
         */
        QTableWidget* _tableWidget = nullptr;
        /**
         * @brief  直接坐标系图表
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-18
         */
        Plot::FITKXYPlotWindow* _xyPlotWindow = nullptr;
        /**
         * @brief  曲线配置属性选项界面
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-20
         */
        GUICurvePlotSettingsDialog* _curvePlotSettingWidget = nullptr;
        /**
         * @brief  频率数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-21
         */
        std::vector<float> _freqValue;
        /**
         * @brief  参数数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-21
         */
        QHash<QString, std::vector<float>> _paraValue;
        /**
         * @brief  DB计算乘积
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-03-07
         */
        double _dBDefault{ 10 };
    };
}


#endif // _GUIAbsPostCurvePlotWidget_H
